package main

import (
	"flag"
	"github.com/tal-tech/go-zero/core/conf"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"karnin-zero-admin/service/sys/model"
)

var configFile = flag.String("f", "etc/sys-migrate.yaml", "the config file")
type Config struct {
	Gorm struct{
		DSN string
	}
}

func main() {
	flag.Parse()
	var c Config
	conf.LoadConfig(*configFile,&c)
	db, _ := gorm.Open(mysql.New(mysql.Config{DSN: c.Gorm.DSN}), &gorm.Config{
		DisableForeignKeyConstraintWhenMigrating: true,
	})
	db.Set("gorm:table_options", "ENGINE=InnoDB charset=utf8mb4 comment='用户表'").AutoMigrate(&model.Config{})
}
